import Vue from "vue";
import Vuex from "vuex";
import Cart from "./Cart"
import Product from "./Product"
import logPlugin from "./plugins/test"

//plugins值是一个数组,数组中的每个元素都是必须是一个方法(函数)
import createPersistedstate from "vuex-persistedstate"
import storageProducts from "./plugins/storageProducts"
Vue.use(Vuex);

export default new Vuex.Store({ //根store rootStore
  state: {
    name: "李雷"
  },
  mutations: {
    SET_PRODUCT() {

    }
  },
  actions: {},
  getters: {},
  modules: {//模块化
    Product,
    Cart
  },
  plugins: [createPersistedstate({
    storage: window.localStorage,//选择存储方式
    key: 'cart-app',
    // 模块化的缓存 使用模块的名字.要缓存的属性就可以了
    paths: ["name", "Cart.carts"]
  }), logPlugin, storageProducts]
});